package com.itheima.demo03functionalinterface;

import java.util.Arrays;
import java.util.function.Supplier;

public class Demo02Supplier {
    public static void main(String[] args) {
        //使用Lambda表达式返回数组元素最大值
        System.out.println("开始了");
        printMax(() -> {
            int[] arr = {11, 99, 88, 77, 22};
            Arrays.sort(arr);
            return arr[arr.length - 1];
        });
    }

    public static void printMax(Supplier<Integer> supplier) {
        int max = supplier.get();
        System.out.println("max=" + max);
    }
}
